﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.Mvc;
using Revis.VClinicNet.App.Internal.Dto.Validation;

namespace Revis.VClinicNet.UI.Internal.Mvc.Extensions
{
    public static class ModelStateDictionaryExtensions
    {
        public static void AddModelErrors(
            this ModelStateDictionary modelState,
            ValidationException validationException)
        {
            foreach (ValidationError vr in validationException.Errors) {
                modelState.AddModelError(vr.Key, vr.Message);
            }
        }

        public static readonly string ErrorMessageKey = "ErrorMessageKey";

        public static void AddErrorMessage(
            this ModelStateDictionary modelState,
            string message)
        {
            modelState.AddModelError(ErrorMessageKey, message);
        }
    }
}